﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;

public partial class frmDiagnosisDrugs : BaseWinFrom
{
    DataTable dt = null;

    public frmDiagnosisDrugs()
    {
        InitializeComponent();
        ThreadPool.QueueUserWorkItem(ThreadHandle);
    }

    void ThreadHandle(object sender)
    {
        NetTableBridge.Client c = new NetTableBridge.Client(new byte[] { 127, 0, 0, 1 }, 18918);
        DataTable dt = c.ExcuteDataTable("L");
        Invoke(new EventHandler(InvokeHand), new object[] { dt, null });
        Thread.Sleep(2000);
    }

    void InvokeHand(object sender, EventArgs e)
    {
        DataTable t = sender as DataTable;
        if (t == null)
            return;
        if (dt == null)
        {
            dt = t;
        }
        else
        {
            foreach (DataRow i in dt.Rows)
            {
                foreach (DataRow j in t.Rows)
                {
                    if (i["Id"].ToString() == j["Id"].ToString())
                    {
                        t.Rows.Remove(j);
                        break;
                    }
                }
            }
            dt.Merge(t);
        }
        dgvList.DataSource = dt;
    }
    //A
}